<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
<title>会员消费</title>
<meta name="decorator" content="default" />
<script type="text/javascript">
	function cacheEmployees() {
		jQuery.ajax({
			url : "${ctx}/employee/employee/employeeData",
			type : "post",
			data : {},
			success : function(data) {
				sessionStorage.employees = data;
			},
			error : function(data) {
				showTip("获取员工列表失败");
			}
		});
	}

	//TODO
	function cacheSystemProduct() {
		jQuery.ajax({
			url : "${ctx}/base/storeProduct/storeProductData",
			type : "post",
			data : {
				type : 0
			},
			success : function(data) {
				sessionStorage.systemProducts = data;
			},
			error : function(data) {
				showTip("获取系统产品失败");
			}
		});
	}

	//TODO
	function cacheStoreProduct() {
		jQuery.ajax({
			url : "${ctx}/base/storeProduct/storeProductData",
			type : "post",
			data : {
				type : 0
			},
			success : function(data) {
				sessionStorage.storeProducts = data;
			},
			error : function(data) {
				showTip("获取系统产品失败");
			}
		});
	}
	function page(n, s) {
		$("#pageNo").val(n);
		$("#pageSize").val(s);
		$("#searchForm").submit();
		return false;
	}
	
	$(document).ready(function() {
		cacheEmployees();
		cacheSystemProduct();
		cacheStoreProduct();
	});
</script>
<style type="text/css">
.container {
	width: 95%;
	margin: auto;
	text-align: center;
}
</style>
</head>
<body>
	<div class="container">
		<tags:message content="${message}" />
		<div class="icon-buttons">
			<a data-role="button" data-inline="true" data-icon="back"
				data-iconpos="notext" href="${ctx}">返回</a>
		</div>

		<form:form id="searchForm" modelAttribute="customerQuery"
			action="${ctx}/cash/member/query" method="post"
			class="breadcrumb form-search">
			<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}" />
			<input id="pageSize" name="pageSize" type="hidden"
				value="${page.pageSize}" />
			<input type="button" value="客户添加" data-inline="true"
				onclick="loginPasswordPopup('${ctx}/base/customer/form?target=cash/member')">
			<fieldset data-role="controlgroup" data-type="horizontal"
				data-inline="true">
				<form:radiobutton path="searchType" value="0" label="姓名 " />
				<form:radiobutton path="searchType" value="1" label="备注名 " />
				<form:radiobutton path="searchType" value="2" label="手机号码 " />
			</fieldset>
			<form:input path="keyWords" type="search" data-inline="true" />
			<input id="btnSubmit" data-inline="true" type="submit" value="查询" />
		</form:form>
		<table id="contentTable" data-role="table"
			class="ui-responsive table-stroke">
			<thead>
				<tr>
					<th style="width:20em">姓名</th>
					<th style="width: 20em">备注名</th>
					<th style="width: 20em">电话</th>
					<th style="width: 20em">护理项目</th>
					<th style="width: 20em">专属美容师</th>
					<th style="width: 20em">上次到店时间</th>
				</tr>
			</thead>
			<tbody>
				<c:forEach items="${page.list}" var="customerInfo">
					<tr
						onclick="directOpenURL('${ctx}/cash/member/detail?id=${customerInfo.customer.id}')"
						style="height:3em">
						<td>${customerInfo.customer.name}</td>
						<td>${customerInfo.customer.nickname}</td>
						<td>${fns:replaceTel(customerInfo.customer.mobile)}</td>
						<td><c:forEach var="storecare" items="${customerInfo.cares}">
								<c:choose>
									<c:when test="${storecare.care_type==0}">
						        ${storecare.care.name}<br />
									</c:when>
									<c:when test="${storecare.care_type==1}">
						       ${storecare.storeSelfCare.name}<br />
									</c:when>
								</c:choose>
							</c:forEach></td>
						<td><c:forEach var="employee"
								items="${customerInfo.employees}">
						${employee.name}<br />
							</c:forEach></td>
						<td>${fns:formatDate(customerInfo.lastComingDate,'yyyy-MM-dd
							HH:mm:ss')}</td>
					</tr>
				</c:forEach>
			</tbody>
		</table>
		<div class="pagination">${page}</div>
	</div>
</body>
</html>
